package P150;

/**
 * @author LiangMu
 * @version \$Id: P25.java, v 0.1, 2024年07月05日 14:59 LiangMu Exp $$
 */
public class P25 {

    public int[] twoSum(int[] numbers, int target) {
        int left = 0;
        int right = numbers.length - 1;
        while (left < right) {
            int sum = numbers[left] + numbers[right];
            if (sum > target) {
                --right;
            } else if (sum < target) {
                ++left;
            } else {
                return new int[]{
                    left + 1,
                    right + 1
                };
            }
        }
        throw new RuntimeException();
    }
}
